# https://taxi.jtzyzg.org.cn/CZCJSY/LEAP/czcjsy/html/lawsRegulations.html
import requests
import execjs

cookies = {
    'JSESSIONID': '9222434907BD2C57833DD46CD04D3F81.04',
    'Hm_lvt_dc5ba73b9a2575893c22e350cee52bc9': '1698895079',
    'Hm_lpvt_dc5ba73b9a2575893c22e350cee52bc9': '1699490576',
}

headers = {
    'Accept': 'application/json, text/javascript, */*; q=0.01',
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Connection': 'keep-alive',
    'Content-Type': 'application/json',
    # 'Cookie': 'JSESSIONID=9222434907BD2C57833DD46CD04D3F81.04; Hm_lvt_dc5ba73b9a2575893c22e350cee52bc9=1698895079; Hm_lpvt_dc5ba73b9a2575893c22e350cee52bc9=1699490576',
    'Origin': 'https://taxi.jtzyzg.org.cn',
    'Referer': 'https://taxi.jtzyzg.org.cn/CZCJSY/LEAP/czcjsy/html/lawsRegulations.html',
    'Sec-Fetch-Dest': 'empty',
    'Sec-Fetch-Mode': 'cors',
    'Sec-Fetch-Site': 'same-origin',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
    'X-Requested-With': 'XMLHttpRequest',
    'sec-ch-ua': '"Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
}
file_js = open('出租车解析JS.js', 'r', encoding='utf-8').read()

#获取加密参数
def encrypt_data(page):
    data = '{"bean": {"pageSize": 10,"pageNum": "'+str(page)+'","sys": 7,"newstype": "0104"}}'

    return {
        "service": execjs.compile(file_js).call('a', 'LTPU_getNewsList'),
        "version": execjs.compile(file_js).call('a', '1.0.0'),
        "data": execjs.compile(file_js).call('a', data),
    }

response = requests.post(
    'https://taxi.jtzyzg.org.cn/CZCJSY/restservices/http/single/query',
    cookies=cookies,
    headers=headers,
    json=encrypt_data(1),
).json()

for item in response['result']['result']['result']:
    print(item)
